<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>采购计划</title>
</head>
<body>
<script type="text/javascript">
$(function(){
	$("#eos_select_open").textbox({onClickButton: function(){
		$("#eqOfficeSuppl_select").window("open");
		$("#eqOfficeSuppl_select").panel("refresh");
	}});
});

function savequit(){
	$("#form_add_equipplanla").form({
		onSubmit: function(param){
			var rows = $("#equip_add_dg").datagrid("getRows");
			for(var i = 0; i < rows.length; i ++){
				param['planDetails[' + i +'].edetailName3'] = rows[i].edetailName3;
				param['planDetails[' + i +'].edetailNum'] = rows[i].edetailNum;
				param['planDetails[' + i +'].edetailUnit'] = rows[i].edetailUnit;
				param['planDetails[' + i +'].edetailType'] = rows[i].edetailType;
			}
			var isValid = $(this).form('validate');
			if (!isValid){
				$.messager.progress('close');	// 如果表单是无效的则隐藏进度条
			}
			return isValid;	// 返回false终止表单提交	
		},
		success: function(v){
			var json = eval("(" + v + ")");
			$.messager.alert("操作提示", 
					json.success ? "操作成功" 
					: ("操作失败，原因为：" + json.reason));
			$("#form_add_equipplanla").form("clear");
			var rows = $("#equip_add_dg").datagrid("getRows");
			for(var i=rows.length-1;i>=0;i--){
				$('#equip_add_dg').datagrid('deleteRow', i);
			}
		}
	});
	$("#form_add_equipplanla").submit();
	
}
</script>
	<div class="easyui-panel" title="采购计划" 
		border="false" fit="true" >
		<form  id="form_add_equipplanla" action="add_equiplan" method="post">
			<table width="100%" border="0" style="padding:6px;">
				<tr>	
					<td width="30%"> 
						<input name="eplan.eplanAuthor" style="width:50%;" class="easyui-textbox" label="制定人" 
						data-options="required:true,validType:'isBlank'"> 
					</td>
					<td width="35%">
						<select name="eplan.eplanDept" style="width:60%;" class="easyui-combotree" label="采购科室" 
						data-options="url:'to_QueryAllOffice',required:true,validType:'isBlank',valueField:'text'">		
						</select>
					</td>
					<td width="35%">
						<select name="eplan.eplanType" style="width:50%;" class="easyui-combobox" label="采购类型" 
						data-options="panelHeight: 'auto',required:true,validType:'isBlank'">
								<option value="批次采购">批次采购</option>
								<option value="补货采购">补货采购</option>
						</select>
					</td>
				</tr>
				<tr>
					<td width="30%"> 
						<input name="eplan.eplanTitle" style="width:80%;" class="easyui-textbox" label="采购计划标题"
						data-options="required:true,validType:'isBlank'"> 
					</td>
					<td width="35%">
						<input name="eplan.eplanDate" style="width:60%;" class="easyui-datebox" label="申请日期" value="1"
						data-options="required:true,validType:'isBlank'" >
						<input name="eplan.eplanState" value="待审核" type="hidden">
					</td>	
				</tr>
			</table>
			
			<div class="easyui-tabs" border="false" style="width:100%;">
				<div title="采购计划明细">
					<table>
						<tr>
							<td width="40%"><input id="eos_select_open" class="easyui-textbox"
								label="设备器材" data-options="buttonText:'选择',width:285"></td>
						</tr>
						<tr>
							<td width="30%"><input id="rdetail_num" class="easyui-numberbox"
								label="数量" data-options="min:0">
							</td>
							<td width="30%"><input id="rdetail_comp" class="easyui-combobox"
								label="单位" readonly="readonly"
								data-options="panelHeight: 'auto',	
									valueField: 'label',
									textField: 'label',
									">
							</td>
							<td width="30%"><input id="rdetail_type" class="easyui-textbox" readonly="readonly"
								label="类型" data-options="width:180">
							</td>		
						</tr>
					</table>
					<div id="eqOfficeSuppl_select" class="easyui-window" title="选择设备器材"
					data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-add',closed:true,href:'equip_supply_office'"
					style="width: 810px; height: 400px; padding: 5px;">
					
					</div>
					<div id="plan_tb">
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendESO()">添加一行</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">删除一行</a>
					</div>
					<table style="width:100%;" id="equip_add_dg" class="easyui-datagrid" data-options="
						singleSelect: true,
						fitColumns: true, nowrap: false,
						rownumbers: true, 
						border: false,
						onDblClickCell: onClickCell,
						onSelect: onSelect,
						rownumbers: true
					">
						<thead>
							<tr>
								<th style="width:40%;" data-options="field:'edetailName3'">采购设备器材名</th>
								<th style="width:15%;" data-options="field:'edetailNum'">数量</th>
								<th style="width:15%;" data-options="field:'edetailUnit'">单位</th>
								<th style="width:30%;" data-options="field:'edetailType'">类型</th>
							</tr>
						</thead>
						
					</table>
				</div>
			</div>
			<div style="margin: 5px 3px;">
				<a href="#" class="easyui-linkbutton" 
				data-options="onClick:savequit" iconCls="icon-save">保存采购计划</a>
			</div>
		</form>	
	</div>
</body>
</html>